package ATMproject;

import jframe.LoginPanel;

import javax.swing.*;
import java.awt.*;
import java.util.Date;

public class MainPage extends JFrame {
    //声明其他跳转类
    private Login login = new Login(this);
    private Menu menu = new Menu(this);
    private Save save = new Save(this);
    private Draw draw = new Draw(this);
    private Inquire inquire = new Inquire(this);

    //声明布局类
    private CardLayout cardLayout = new CardLayout();

    //加背景图
    private Image backgroundimg = Util.getImage("/atmimage/background.jpg");


    public MainPage() {
        this.setContentPane(new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(backgroundimg, 0, 0, 800, 600, this);
            }
        });

        this.setLayout(cardLayout);

        //传其他页面
        this.add("login", login);
        this.add("menu",menu);
        this.add("save",save);
        this.add("draw",draw);
        this.add("inquire",inquire);

        this.setSize(800, 600);
        this.setTitle("主界面");
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setVisible(true);
    }

    //换页面的方法
    public void switchPanel(String name) {
        cardLayout.show(this.getContentPane(), name);
    }


    public static void main(String[] args) {
        new MainPage();
    }
}
